package com.xinhua.erp.controller;

import com.xinhua.erp.pojo.ProductClass;
import com.xinhua.erp.pojo.Result;
import com.xinhua.erp.service.ProductClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("productClass")
public class ProductClassController {

    @Autowired
    private ProductClassService productClassService;

    @GetMapping("{id}")
    public Result findById(@PathVariable long id){

        return productClassService.findById(id);

    }

    @GetMapping
    public Result findAll() {

        return productClassService.findAll();

    }

    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable long id){

        return productClassService.deleteById(id);

    }

    @PostMapping
    public Result save(@RequestBody ProductClass productClass){

        return productClassService.save(productClass);

    }

    @PutMapping("{id}")
    public Result update(@RequestBody ProductClass productClass,@PathVariable Long id){

        return productClassService.update(productClass,id);

    }

    @GetMapping("parent/{parentId}")
    public Result findByParentId(@PathVariable long parentId){

        return productClassService.findByParentId(parentId);

    }


}
